package com.kecheng.xinmei.controller;

import com.kecheng.xinmei.entity.OrderDTO;
import com.kecheng.xinmei.model.PageOrder;
import com.kecheng.xinmei.model.USDValueDTO;
import com.kecheng.xinmei.model.UserNftCollectionDTO;
import com.kecheng.xinmei.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/pop")
public class POPController {
    @Autowired
    private UserService userService;
    @GetMapping(value = "/get_nft")
    public UserNftCollectionDTO getNFT(@RequestParam("address") String address,@RequestParam("pageSize") Integer pageSize){
        UserNftCollectionDTO  userNftCollectionDTO = userService.getMyNFT(address, pageSize);
        return userNftCollectionDTO;
    }

    @GetMapping(value = "/get_value")
    public List<USDValueDTO> getValue(@RequestParam("address") String address){
        List<USDValueDTO>   usdValueDTOList = userService.getValue(address);
        return usdValueDTOList;
    }

    @PostMapping(value = "/place_order")
    public Boolean placeOrder(@RequestBody OrderDTO orderDTO){
        Boolean   usdValueDTOList = userService.placeOrder(orderDTO);
        return usdValueDTOList;
    }

    @GetMapping(value = "/get_order")
    public PageOrder getOrder(@RequestParam("pageNum")Integer pageNum, @RequestParam("pageSize")Integer pageSize){
        PageOrder   usdValueDTOList = userService.getOrder(pageNum,pageSize);
        return usdValueDTOList;
    }

    @GetMapping(value = "/get_my_order")
    public UserNftCollectionDTO getMyOrder(@RequestParam("address")String address,@RequestParam("pageNum")Integer pageNum, @RequestParam("pageSize")Integer pageSize){
        UserNftCollectionDTO   usdValueDTOList = userService.getMyOrder(address.toLowerCase(),pageNum,pageSize);
        return usdValueDTOList;
    }
    @GetMapping(value = "/bought_order")
    public Boolean boughtOrder(@RequestParam("address")String address,@RequestParam("orderId")Integer orderId){
        Boolean   usdValueDTOList = userService.boughtOrder(address.toLowerCase(),orderId);
        return usdValueDTOList;
    }
}
